#!/usr/bin/perl -w
use strict;

my $file_dir = $ARGV[0];

opendir(DIR, $file_dir) ||
	die ("Unable to open: $file_dir\n");
my @files = grep {(!/^\./)} readdir(DIR);
closedir (DIR);

for (my $k = 0; $k < scalar(@files); $k++){ 
	&get_journal ($files[$k]);	
}

sub get_journal{ 
	;
	my ($file) = @_;
	my $path = $file_dir . "/" . $file;
	open (FD, $path) ||
		die ("Unable to open: $path\n");
	while (<FD>){ 
		chop;
		$_ =~ s/^\ +//g;
		next if (not $_ =~ /^\<Title\>/);
		$_ =~ s/\<Title\>//g; 
		$_ =~ s/\<\/Title\>//g;
		my $id = $file;
		$id =~ s/\.xml//;
		print $id . "," . $_ . "\n";
		
	}
	close (FD);	
}
